package com.ztz.mynewdemo.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ztz.mynewdemo.R;
import com.ztz.mynewdemo.adapter.MyAdapterTwo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wqewqe on 2017/5/18.
 */

public class JokeFragment extends Fragment {
    TabLayout tabJoke;
    ViewPager vp;
    MyAdapterTwo adapter;
    List<Fragment> fragmentList=new ArrayList<>();
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.joke_fragment,container,false);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        tabJoke=(TabLayout)view.findViewById(R.id.joke_tab);
        vp=(ViewPager)view.findViewById(R.id.vp_joke);
        fragmentList.add(new UpdateJokeFragment());
        fragmentList.add(new UpdateAmusingFrg());
        adapter=new MyAdapterTwo(getFragmentManager(),fragmentList);
        vp.setAdapter(adapter);
        tabJoke.setupWithViewPager(vp);
    }
}
